package com.example.demo.core.util;

public class SqlUtils {

    public static String trimAndEscape(String keyword) {
        if (keyword == null) {
            return "";
        }
        StringBuilder sb = new StringBuilder(keyword.trim());
        for (int i = 0; i < sb.length(); i++) {
            String c = String.valueOf(sb.charAt(i));
            if ("%_\\".contains(c)) {
                sb.insert(i, "\\");
                i++;
            }
        }
        return sb.toString();
    }
}
